<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    html,
    body {
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
    }

    .bg {
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    div:nth-child(1) {
        background: url('../public/img/1.jpg') center no-repeat;
        background-size: 100%;
    }

    div:nth-child(2) {
        background: url('../public/img/2.jpg') center no-repeat;
        background-size: 100%;
    }

    div:nth-child(3) {
        background: url('../public/img/3.jpg') center no-repeat;
        background-size: 100%;
    }

    div:nth-child(4) {
        background: url('../public/img/4.jpg') center no-repeat;
        background-size: 100%;
    }

    div:nth-child(5) {
        background: url('../public/img/5.jpg') center no-repeat;
        background-size: 100%;
    }

    div:nth-child(6) {
        background: url('../public/img/1.jpg') center no-repeat;
        background-size: 100%;
    }

    h1 {
        text-shadow: 1px;
        z-index: 1;
        font-weight: 600;
    }
</style>

<body>
    <div class="bg">
        <h1>春江潮水连海平，海上明月共潮生。</h1>
    </div>
    <div class="bg">
        <h1>滟滟随波千万里，何处春江无月明！</h1>
    </div>
    <div class="bg">
        <h1>江流宛转绕芳甸，月照花林皆似霰。</h1>
    </div>
    <div class="bg">
        <h1>空里流霜不觉飞，汀上白沙看不见。</h1>
    </div>
    <div class="bg">
        <h1>江天一色无纤尘，皎皎空中孤月轮。</h1>
    </div>
    <div class="bg">
        <h1>江畔何人初见月？江月何年初照人？</h1>
    </div>
</body>

</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.0/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.0/ScrollTrigger.min.js"></script>
<script>
    const allDiv = document.querySelectorAll('div')
    gsap.registerPlugin(ScrollTrigger)
    allDiv.forEach(item => {
        gsap.fromTo(
            item, {
            backgroundPositionY: `-${window.innerHeight / 2}px`
        }, {
            backgroundPositionY: `${window.innerHeight / 2}px`,
            ease: 'none',
            scrollTrigger: {
                trigger: item,
                scrub: true
            }
        }
        )
    })
</script>

</html>